import 'package:base_flutter/base_flutter.dart';
import 'package:ls_work/model/medicine_advice_model.dart';
import 'package:ls_work/net/response/medicine_advice/medicine_elder_list_data.dart';
class ChooseMedicineElderViewModel extends BaseListViewModel<MedicineElderListData>{
  ChooseMedicineElderViewModel(super.context);

  var model = MedicineAdviceModel();

  var searchName = "";

  static List<PickerDataWithIdModel> typeList = [
    PickerDataWithIdModel(pickId: '0',pickName: '按姓名'),
    PickerDataWithIdModel(pickId: '1',pickName: '按房间'),
  ];

  PickerDataWithIdModel type = typeList.first;

  @override
  Future<List<MedicineElderListData>> requestListData() async {
    return await model.medicineElder(page: page,rows: pageLength,customerNameLike: type.pickId=='0'?searchName:null,bedNoLike: type.pickId=='1'?searchName:null);
  }

  @override
  void onCreated() {
    super.onCreated();
    requestRefresh();
  }

  void chooseType(){
    DataPickerView(context, typeList,currentFirstData: type,onSubmitListener: (p1,p2,p3){
      type = typeList[p1];
      notifyListeners();
      if(searchName.isNotEmpty){
        requestRefresh();
      }
    }).show();
  }

}